package com.spring.mybatis.service.impl;

import com.spring.mybatis.dao.UserMapper;
import com.spring.mybatis.service.UserService;
import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserServiceImpl implements UserService {
	@Autowired
	private UserMapper userMapper;

	@Override
	public void test1() {
		userMapper.queryUser();
	}

	@Override
	@Transactional
	public void test2() {
		userMapper.insert1();
		((UserServiceImpl)AopContext.currentProxy()).test3();
	}

	@Override
	@Transactional(propagation = Propagation.REQUIRES_NEW)
	public void test3() {
		userMapper.insert2();
		((UserServiceImpl)AopContext.currentProxy()).test4();
	}

	@Override
	@Transactional(propagation = Propagation.REQUIRES_NEW)
	public void test4() {
		userMapper.insert3();
	}
}
